#ifndef _AMERICO_LINE_VOLUME_H_
#define _AMERICO_LINE_VOLUME_H_

#include <vector>
#include "line.h"

namespace Intersection
{
	namespace I2D
	{
		template <typename TYPE>
		class LineVolume
		{
		private:
			std::vector< Line<TYPE> > myLineList;

		public:
			LineVolume();
			LineVolume(std::vector< Line<TYPE> > aLineList);
			void AddLine(const Line<TYPE> &aLine);
			void RemoveLine(const Line<TYPE> &aLine);
			bool Inside(const Vector2<TYPE> &aPosition) const;
		};

		template <typename TYPE>
		LineVolume<TYPE>::LineVolume()
		{
		}

		template <typename TYPE>
		LineVolume<TYPE>::LineVolume(std::vector< Line<TYPE> > aLineList)
		{
			myLineList = aLineList;
		}

		template <typename TYPE>
		void LineVolume<TYPE>::AddLine(const Line<TYPE> &aLine)
		{
			myLineList.push_back(aLine);
		}

		template <typename TYPE>
		void LineVolume<TYPE>::RemoveLine(const Line<TYPE> &aLine)
		{
			for(unsigned int index=0; index<myLineList.size(); ++index)
			{
				if(myLineList[index] == aLine)
				{
					myLineList.erase(myLineList.begin()+index);
					return;
				}
			}
		}

		template <typename TYPE>
		bool LineVolume<TYPE>::Inside(const Vector2<TYPE> &aPosition) const
		{
			for(unsigned int index=0; index<myLineList.size(); ++index)
			{
				if(myLineList[index].Inside(aPosition) == false)
				{
					return false;
				}
			}
			return true;
		}
	};
};

#endif
